import { createRouter, createWebHashHistory } from "vue-router";
import Main from "@/views/Main.vue";
import Home from "@/views/Home.vue";
import User from "@/views/User.vue";
import Mall from "@/views/Mall.vue";
import Login from "@/views/Login.vue";

//自定路由规则
const routes = [
  {
    path: "/",
    name: "main",
    component: Main,
    redirect: "/home",
    children: [
      {
        path: "home",
        name: "home",
        component: Home,
      },
      {
        path: "user",
        name: "user",
        component: User,
      },
      {
        path: "mall",
        name: "mall",
        component: Mall,
      },
    ],
  },
  {
    path: "/login",
    name: "login",
    component: Login,
  },
  {
    path: "/404",
    name: "404",
    component: () => import("@/views/404.vue"),
  },
];

//设置模式
const router = createRouter({
  history: createWebHashHistory(),
  routes,
});
// 导出
export default router;
